home *** CD-ROM | disk | FTP | other *** search
/ Dream 55 / Amiga_Dream_55.iso / RISCOS / APPS / TEXT / PS / KIT-PS.ZIP / Kit PS / !PSUtils / pl / fixdlsrps < prev    next >
Text File  |  1997-01-24  |  2KB  |  62 lines

  1. @rem = '-*- Perl -*-
  2. @echo off
  3. perl -S %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9
  4. goto endofperl
  5. ';
  6.  
  7. # fixdlsrps: fix DviLaser/PS document to work with PSUtils
  8. #
  9. # Copyright (C) Angus J. C. Duggan 1991-1995
  10. # See file LICENSE for details.
  11.  
  12. $nesting = 0;
  13. $page = 1;
  14. $infont = 0;
  15.  
  16. @fonts = ();
  17. @body = ();
  18. $header = 1;
  19.  
  20. while (<>) {
  21.    if (/^XP/) {
  22.       $infont++;
  23.       push(@fonts, $_);
  24.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  25.    } elsif ($infont) {
  26.       push(@fonts, $_);
  27.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  28.    } elsif ((/^%%EndSetup/ || /^%%Page:/) && $header) {
  29.       print @body;
  30.       @body = ("%%EndSetup\n");
  31.       $header = 0;
  32.    } elsif (/^%%EndProlog/ && !$nesting) {
  33.       push(@body,
  34.        "\$DviLaser begin/GlobalMode{}bdef/LocalMode{}bdef/XP{}def/RP{}def",
  35.        "/DoInitialScaling{72.0 Resolution div dup scale}bdef end\n", $_);
  36.    } elsif (/^%%BeginPageSetup/ && !$nesting) {
  37.       push(@body, "%%Page: $page $page\n", $_,
  38.         "Resolution 72 div dup scale Magnification 1000 div dup scale\n",
  39.         "/DocumentInitState where {\n",
  40.         "/DocumentInitState [ matrix currentmatrix currentlinewidth",
  41.         " currentlinecap currentlinejoin currentdash currentgray",
  42.         " currentmiterlimit] cvx put}if\n");
  43.       $page++;
  44.    } elsif (/^%%BeginDocument:/ || /^%%BeginBinary:/ || /^%%BeginFile:/) {
  45.       push(@body, $_);
  46.       $nesting++;
  47.    } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) {
  48.       push(@body, $_);
  49.       $nesting--;
  50.    } elsif (!/^%%PageBoundingBox:/ && !/^%%Page:/) {
  51.       push(@body, $_);
  52.    }
  53. }
  54.  
  55. print @fonts;
  56. print @body;
  57.  
  58. exit 0;
  59. __END__
  60. :endofperl
  61.  
  62.